<html>
<head>
<title>我的订单</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/css/product.css?v=2013-11-30">
<link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/css/page.css?v=2013-11-21">
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/alertMsg.js"></script>
<script src="{$Think.config.RESOURCEURL}http://res.wx.qq.com/mmbizwap/en_US/htmledition/js/wxm-core1530d0.js"></script>

<style type="text/css">
.page-url {
	text-align: center;
	font-size: 12px;
}
</style>
<script type="text/javascript">

var hrefParamsArray = GetSessionIdFromHref(window.location.search);
hrefParamsArray["userName"]='{$userName}';
function GetSessionIdFromHref(search){
　　	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
		for(var i = 0; i < args.length; i ++){ 
			str = args[i]; 
			var arg = str.split("="); 
			if(arg.length <= 1) continue; 
			
			if(arg[0] == 'params') {
				var params = decodeURIComponent(arg[1]);
				var obj = eval('(' + params + ')');
				if (obj.start == undefined) {
					retval["start"] = 0;
				} else {
					retval["start"] = obj.start;
				}
				retval["sid"] = obj.sid;
			} else if(arg[0] == 'customerId') {
				retval["customerId"] = arg[1]; 
			}else if(arg[0] == 'userName'){
				retval["userName"] = arg[1]; 
			}
		} 
		if (retval["start"] == undefined) {
			retval["start"] = 0;
		}
		return retval; 
}

var limit = 10;
var pageCount = Math.ceil({$total} / limit);
var page = Math.ceil(hrefParamsArray["start"] / limit) + 1;
</script>
</head>

<body id="onlinebooking-list">
	<div class="cardexplain">
		<volist name="results" id="result">
			<ul class="round">
				<script>
					var oid = {$result.id};
					var sid = {$result.storeId};
					document.write("<a onclick='orderDetail(this," + oid + "," + sid + ");'>")</script>
					<li class="title">
						<span class="arrow">订单详情</span>
					</li>
					<li>
						<div class="text">
							<p>订单编号 ：{$result.serialNumber}</p>
							<p>订单状态 ：
							<notempty name="result.status">
				                <if condition="$result.status eq 'ok'">[交易成功]
				                <elseif condition="$result.status eq 'closed'"/>[交易关闭]
				                <elseif condition="$result.status eq 'paying'"/>[等待付款]
				                <elseif condition="$result.status eq 'delivering'"/>[等待发货]
				                <elseif condition="$result.status eq 'deliveringtostore'"/>[等待配送到自提点]
				                <elseif condition="$result.status eq 'delivered'"/>[已发货]
				                <elseif condition="$result.status eq 'deliveredtostore'"/>[已配送到自提点]
				                <elseif condition="$result.status eq 'notsubmit'" />[未提交]
				                <elseif condition="$result.status eq 'refund'"/>[已退款]
				                <elseif condition="$result.status eq 'refundedpart'"/>[已部分退款]
				                <elseif condition="$result.status eq 'refunding'"/>[退款中]
				                <elseif condition="$result.status eq 'payingconfirm'"/>[付款确认中]
				                <else />[状态错误]
				                </if>
				                </notempty>
				                <empty name="result.status">[未处理]</empty>
				            </p>
							<notempty name="result.price">
							<p>订单金额 ：{$result.price}元</p> 
							</notempty>
							<notempty name="order.remark">
								<p>备注说明 : {$order.remark}</p>
							</notempty>
							<p>提交时间：{$result.updateTime}</p>
						</div>
					</li>
				</a>
			</ul>
		</volist>
	</div>
	<div class="pagination" id="pagination">
		<div id="pagePrev">
		<script>if (page != 1) {
			var start = parseInt(hrefParamsArray["start"]) - limit;
			var urlString = 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
				+ '&module=product&method=getOrder&params={"type":"buy","tplid":2,"start":' + start + '}';
			document.write("<a href='" + urlString + "'>上一页</a>");
		} else {
			document.write("<a href='javascript:void(0)' style='background:none;border:1px solid #cbcbcb;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;color:A4A3A3;cursor: default;'>上一页</a>");
		}
		</script>
		</div>
		<div class="allpage">
			<div class="currentpage"><script>document.write(page + "/" + pageCount);</script></div>
		</div>
		<div id="pageNext">
		<script>if (page != pageCount) {
			var start = parseInt(hrefParamsArray["start"]) + limit;
			var urlString = 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
				+ '&module=product&method=getOrder&params={"type":"buy","tplid":2,"start":' + start + '}';
			document.write("<a href='" + urlString + "'>下一页</a>");
		} else {
			document.write("<a href='javascript:void(0)' style='background:none;border:1px solid #cbcbcb;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;color:A4A3A3;cursor: default;'>下一页</a>");
		}
		</script>
		</div>
	</div>
<script type="text/javascript">

if(pageCount == 1 && page == pageCount){
	document.getElementById("pagination").style.display="none";
}

function orderDetail(ctrl,oid, sid) {
	ctrl.href = 'call.html?userName=' + hrefParamsArray['userName'] + '&customerId='
	+ hrefParamsArray['customerId'] + '&module=product&method=getOrderDetail&params={"id":"' + oid +'","tplid":4}';
}
</script>

<script type="text/javascript">
function resetAndAppendHerf(search){
　　	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
	for(var i = 0; i < args.length; i ++){ 
		str = args[i]; 
		var arg = str.split("="); 
		if(arg.length <= 1) continue; 
		if(arg[0] == 'userName'){
			args[i] = "userName=";
		}
	} 
	return args.join("&");
}

$(function(){
	var imageUrl = '';
	var title = '我的订单';
	var des = '点击这里查看我购买的商品';
	var search = '?' + resetAndAppendHerf(window.location.search);
	var shareUrlString = window.location.protocol + "//"
			+ window.location.host + window.location.pathname + search;	      
	
	window.shareData = {
		"imgUrl": imageUrl,
		"timeLineLink":  shareUrlString ,
		"sendFriendLink":  shareUrlString ,
		"weiboLink":  shareUrlString ,
		"tTitle": title,
		"tContent": des,
		"fTitle": title,
		"fContent": des,
		"wContent": des
	};
	document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
		// 发送给好友
		WeixinJSBridge.on('menu:share:appmessage', function (argv) {
			WeixinJSBridge.invoke('sendAppMessage', {
				"img_url":  window.shareData.imgUrl,
				"img_width": "640",
				"img_height": "640",
				"link": window.shareData.sendFriendLink,
				"desc": window.shareData.fContent,
				"title": window.shareData.fTitle
			}, function (res) {
				_report('send_msg', res.err_msg);
			})
		});
	
		// 分享到朋友圈
		WeixinJSBridge.on('menu:share:timeline', function (argv) {
			WeixinJSBridge.invoke('shareTimeline', {
				"img_url": window.shareData.imgUrl,
				"img_width": "640",
				"img_height": "640",
				"link": window.shareData.timeLineLink,
				"desc": window.shareData.tContent,
				"title": window.shareData.tTitle
			}, function (res) {
				_report('timeline', res.err_msg);
			});
		});
	
		// 分享到微博
		WeixinJSBridge.on('menu:share:weibo', function (argv) {
			WeixinJSBridge.invoke('shareWeibo', {
				"content": window.shareData.wContent,
				"url": window.shareData.weiboLink
			}, function (res) {
				_report('weibo', res.err_msg);
			});
		});
	});
});
</script>
</body>
</html>